<div class="layui-form" lay-filter="layuiadmin-form-fpfl" style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px">商品名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template="">
                <input list="options" name="spmc" lay-verify="required" class="layui-input"
                       placeholder="请输入商品名称"
                       value="{{d.params.spmc||''}}"
                       autocomplete="off">
            </script>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px">商品编码</label>
        <script type="text/html" template>
        <div class="layui-input-inline">
            <select id="spmb"   name="spbm" lay-verify="" lay-search lay-filter="spmbxx">
                <option value=""></option>
                {{# if(d.params.spbm){ }}
                {{# layui.each(spmb,function(index,item){  }}
                    <option value={{index}} {{ (d.params.spbm === index ?
                    'selected' : '') }}>{{index+item}}</option>
                {{# }); }}
                    {{#}else{ }}
                    {{# layui.each(spmb,function(index,item){ console.log(11111) }}
                <option value={{index}} >{{index+item}}</option>
                {{# }); }}
                    {{# } }}
            </select>

        </div>
    </script>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px">分类名称</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input id="FLMC" name="flmc" lay-verify="required" class="layui-input"
                       value="{{d.params.flmc||''}}"
                       disabled="disabled"
                       autocomplete="off">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-fpfl-front-submit" value="确认" class="layui-btn mybtn">
        </div>
    </div>
</div>
<script>
    // 获取所有税务机关的信息
    // function getSwjg() {
    //     $.ajax({
    //         url: layui.setter.hostAddr + '/portal/swjg/swjglist',
    //         beforeSend: function (XMLHttpRequest) {
    //             XMLHttpRequest.setRequestHeader("Authorization", layui.data('layuiAdmin', 'Authorization'));
    //         },
    //         dataType: 'json',
    //         type: "GET",
    //         async: false,
    //         success: function (result) {
    //             var option_str = ``
    //             for (var i in result.data) {
    //                 option_str = option_str + `<option value=${result.data[i].swjgdm} >${result.data[i].swjgmc}</option>`
    //             }
    //             $("#swjg").empty()
    //             $("#swjg").append(option_str)
    //         },
    //     });
    //     console.log(111)
    // }


    layui.use(['form'], function () {
        debugger;
        var form = layui.form
        var option_str = `<option value= ></option>`
        for (var i in spmb) {
            option_str = option_str + `<option value=${i} >${i + spmb[i]}</option>`
        }
        $("#spmb").empty()
        $("#spmb").append(option_str)


        form.on('select(spmbxx)', function (data) {
            console.log(data)
            $("#FLMC").val(spmb[data.value])
            $("#FLMC").attr("disabled","disabled");
    	});

        form.verify({
            isExist: function (value) {
                var params = $('.layui-input-inline input[name="name"]').val();
                debugger
                var data;
                // $.ajax({
                //     url: 'http://172.20.10.12:8000/fpfl/',
                //     beforeSend: function (XMLHttpRequest) {
                //         XMLHttpRequest.setRequestHeader("Authorization", layui.data('layuiAdmin', 'Authorization'));
                //     },
                //     contentType: "application/json",
                //     dataType: 'json',
                //     type: "post",
                //     async: false,
                //     data: JSON.stringify({"name": params}),
                //     success: function (result) {
                //         data = result
                //     },
                // });
                if (false) {
                    return '用户id已存在';
                }

            }
        })
    })
</script>



